
public class RockPaperScissors {
	
	Result play(RPSEnum p1, RPSEnum p2){
		if(p1 == RPSEnum.PAPER && p2 == RPSEnum.ROCK 
				|| p1 == RPSEnum.ROCK && p2 == RPSEnum.SCISSORS 
				|| p1 == RPSEnum.SCISSORS && p2 == RPSEnum.PAPER){
			return Result.WIN;
		}
		else if(p1 == p2){
			return Result.TIE;
		}
		else{
			return Result.LOST;
		}
	}
	
	Result play(Player p1, Player p2){
		for(int i = 0; i<p1.getNmoves(); i++){
			Result res = play(p1.getNextMove(), p2.getNextMove());
			if(res == Result.WIN) {
				p1.setScore(p1.getScore()+1);
			}
			else if(res == Result.TIE){
				p1.setScore(p1.getScore()+1);
				p2.setScore(p2.getScore()+1);
			}
			else{
				p2.setScore(p2.getScore()+1);
			}
		}
		return Result.LOST;
	}
}
